﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace Model4D
{
    /// <summary>
    /// Абстрактный класс для описания каркасной модели многомерного объекта.
    /// </summary>
    abstract class AbstractMultiDimModel
    {
        // вершины
        protected List<Vector> _vectors = null;

        // ребра
        protected List<Edge> _edges = null;

        private PointF GetPoint(int index, double offsetX, double offsetY)
        {
            float X = Convert.ToSingle(_vectors[index].X[0] + offsetX);
            float Y = Convert.ToSingle(_vectors[index].X[1] + offsetY);
            return new PointF(X, Y);
        }

        public IEnumerable<Vector> Vectors => _vectors;

        public PointF[] GetPoints(double offsetX, double offsetY)
        {
            PointF[] points = new PointF[2 * _edges.Count];

            for (int i = 0; i < _edges.Count; i++)
            {
                points[2 * i + 0] = GetPoint(_edges[i].Index1, offsetX, offsetY);
                points[2 * i + 1] = GetPoint(_edges[i].Index2, offsetX, offsetY);
            }

            return points;
        }

        /// <summary>
        /// Размерность модели.
        /// </summary>
        abstract public int Dimention { get; }
    }   
}
